package com.smarthealthring.mm.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.smarthealthring.mm.R;
import com.smarthealthring.mm.base.BaseActivity;
import com.smarthealthring.mm.base.IPresenter;
import com.smarthealthring.mm.utils.ComToolBar;
import com.smarthealthring.mm.widgets.itemdecoration.LinearLayoutDecoration;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jakewharton.rxbinding2.view.RxView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 设备类型列表
 * Created by bilibili on 2018/5/15.
 */

public class DevicesActivity extends BaseActivity {

    @BindView(R.id.rv_devices)
    RecyclerView mRvDevices;

    private BaseQuickAdapter mAdapter;

    @Override
    protected void initComToolBar() {
        ImageView ivLeft = ComToolBar.setleftImg(mContext, R.drawable.back_white);
        RxView.clicks(ivLeft)
                .subscribe(o -> finish());
        ComToolBar.setTitle(mContext, "连接智能设备开始绑定");
    }

    @Override
    protected int getLayout() {
        return R.layout.act_devices;
    }

    @Override
    protected void initEventAndData(@Nullable Bundle savedInstanceState) {
        List<String> devices = null;
        mRvDevices.addItemDecoration(new LinearLayoutDecoration(mContext, LinearLayoutDecoration.VERTICAL));
        mRvDevices.setLayoutManager(new LinearLayoutManager(mContext));
        mRvDevices.setAdapter(mAdapter = new BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_device, devices) {
            @Override
            protected void convert(BaseViewHolder helper, String item) {
                helper.setText(R.id.tv_device_kinds, item);
            }
        });
        mAdapter.setNewData(devices = new ArrayList() {{
            add("魔戒");
            add("魔环");
            add("魔棒");
            add("魔表");
        }});

        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                startActivity(new Intent(mContext, CheckBtOpenActivity.class));
            }
        });

    }

    @Override
    protected IPresenter createPresenter() {
        return null;
    }
}
